<template>
  <div>
    <el-row :gutter="20">
      <el-col :span="8" :offset="8">
        <div>
          <div style="display: flex">
            <div class="back-icon" @click="backPage">
              <i class="el-icon-arrow-left"></i>
            </div>
            <h3 class="header-title">测试结果</h3>
            <!-- <h3 class="count-div">{{ evaluate.title }}</h3> -->
          </div>
          <div style="margin: 30px 0px 10px 10px">
            <!-- 图片 -->
            <el-image
              style="width: 30vw; height: 40vh"
              :src="cover"
              fit="fit"
            ></el-image>
          </div>
          <div class="your-avatar">
            <el-image
              style="width: 5vw; height: 5vw"
              :src="avatarUrl"
              fit="fit"
            ></el-image>
            <div class="my-font" style="margin-left: 10px">{{ username }}</div>
          </div>
          <div class="result-div my-font">{{ result }}</div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  props: ["evaluateId", "result"],
  created() {
    this.init();
  },
  data() {
    return {
      cover: "", //封面
      avatar: "", //头像
      username: "", //用户名
      avatarUrl: "",
    };
  },
  methods: {
    init() {
      this.getEvaInfoById();
      this.getUserInfoById();
    },
    //返回上一页
    backPage() {
      this.$router.replace("/evaluation");
    },
    getEvaInfoById() {
      this.$request.getHttp({
        url: "/evaluate/getEvaluateById",
        params: {
          evaluateId: this.evaluateId,
        },
        success: (data) => {
          if (data.code == 200) {
            this.cover = data.evaluate.cover;
          }
        },
        error: (error) => {},
      });
    },
    getUserInfoById() {
      this.$request.getHttp({
        url: "/user/getUserInfoById",
        params: {
          userId: localStorage.getItem("userId"),
        },
        success: (data) => {
          console.log(data);
          if (data.code == 200) {
            this.username = data.user.username;
            this.avatar = data.user.avatar;
            this.avatarUrl = `${this.$store.state.ipAddr}/${this.avatar}`;
          }
        },
        error: (error) => {},
      });
    },
  },
};
</script>

<style scoped>
.back-icon {
  width: 2vw;
  font-size: 25px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-title {
  width: 27vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

.count-div {
  display: flex;
  align-items: center;
  justify-content: center;
}
.count-div-div {
  width: 10vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

.my-font {
  color: #999;
}
.your-avatar {
  display: flex;
  align-items: center;
  margin-left: 10px;
}

.result-div {
  margin: 10px 0px 0px 10px;
  width: 30vw;
}
.start-btn {
  margin-top: 10px;
  margin-left: 10px;
  width: 30vw;
}
</style>